/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hathor.batch;

import com.hathor.conf.PropertyLoader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Kenneth
 */
public class BatchFileGenerator {

    private List<String> batchCommand = new ArrayList<String>();
    private static BatchFileGenerator batchFileGenerator = null;
    private boolean automap;

    private BatchFileGenerator() {
    }

    public static BatchFileGenerator getInstance() {
        if (batchFileGenerator == null) {
            batchFileGenerator = new BatchFileGenerator();
        }
        return batchFileGenerator;
    }

    public File makeBatch(List<String> batchCommand) {

        File tempfile = new File(System.getProperty("user.home") + "/tempMission.bat");
        if (tempfile.exists()) {
            tempfile.delete();
        }
        try {
            // Create file in a temp folder
            tempfile.deleteOnExit();
            FileWriter fstream = new FileWriter(tempfile);
            BufferedWriter out = new BufferedWriter(fstream);
            for (String aString : batchCommand) {
                out.write(aString + System.lineSeparator());
                out.flush();
            }
            //Close the output stream
            out.close();
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        } finally {
            return tempfile;
        }





    }
}
